<template>
  <div class="longin">
<Gback />

    <div class="longin_a">
      <input type="text" v-model="username" />
      <input type="password" v-model="password" />
      {{errMess}}
    </div>
    <button @click="longin">登录</button>
    <button @click="zhuce">还没有账号？</button>
  </div>
</template>
<script>
import Gback from '../components/gback'
export default {
    components:{
Gback
    },
  data() {
    return {
      username: "",
      password: "",
      errMess:''
    };
  },
  methods: {
    longin() {
      this.$axios({
        url: "/api/login",
        method: 'post',
        data:{
            username:this.username,
            password:this.password
        }
      }).then(res=>{
          if(res.data.err===0){
              this.$router.replace("/film");
          }else{
              this.errMess = res.data.msg
          }
      });
    },
    zhuce(){
        this.$router.replace("/reg");
    }
  }
};
</script>
<style scoped>
.longin_a input {
  background-color: darkolivegreen;
}
</style>